def upsert_list_fast(data, new_data):
    temp = {item['symbol']: item for item in data}
    for item in new_data:
        temp[item['symbol']] = item
    return list(temp.values())

def available_balance(walletBalance, positions):
    unRealizedProfit = sum(float(item['unRealizedProfit']) for item in positions)
    initialMargin = sum(float(item['initialMargin']) for item in positions)
    return float(walletBalance) - float(unRealizedProfit) - float(initialMargin)
